package com.lxq.test1903.Main02;

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Stack<Integer> stack = new Stack<Integer>();

        //1对所有表达式求值
        for (int i=0;i<n;i++){
            int sum=0,x1,x2;

            //2.1读取表达式
            String expression = sc.next();
            stack.add(expression.charAt(0)-'0');
            //2.2分析符号
            for (int j=1;j<7;j=j+2){
                char c = expression.charAt(j);
                if (c=='+') {
                    stack.add(expression.charAt(j + 1) - '0');
                }
                if (c=='-') {
                    stack.add('0' - expression.charAt(j + 1));
                }
                if (c=='x') {
                    x1=stack.pop();
                    stack.add(x1*(expression.charAt(j + 1)-'0'));
                }
                if (c=='/') {
                    x1=stack.pop();
                    stack.add(x1/(expression.charAt(j + 1)-'0'));
                }
            }
            //2.3求和栈中剩下数
            while(!stack.empty()){
                sum = sum + stack.pop();
            }
            if (sum==24) System.out.println("Yes");
            else System.out.println("No");
        }
    }
}
